from config import sqlitePath

from sqlalchemy import create_engine
from sqlalchemy.orm import declarative_base, decl_api, sessionmaker

# 数据库连接
db_url = f'sqlite:///{sqlitePath}'

engine = create_engine(db_url, echo=False)
DbBase = declarative_base()  # type: decl_api.DeclarativeMeta
Session = sessionmaker(engine)


def init_create_table(logger):
    logger.info("初始化数据库连接...")
    DbBase.metadata.create_all(bind=engine)
    logger.info("数据库连接成功")
